#include <stdio.h>

#define IN_ORDER 1
#define NOT_IN_ORDER 0


void bubble_sort(int array[], int n)
{
	int i, j;
	int temp = 0;
	int flag;

	for(i = 0; i < n; i++)
	{
		flag = IN_ORDER;
		for(j = 0; j < n - i - 1; j++)
		{
			if(array[j] > array[j+1])
			{
				temp = array[j];
				array[j] = array[j+1];
				array[j+1] = temp;
				flag = NOT_IN_ORDER;
			}
		}
		if(flag == IN_ORDER)
			break;
	}

	for(i = 0; i < n; i++)
		printf("%d\n", array[i]);
}
